<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/5/9
 * Time: 14:25
 */

namespace lib;



class sendSmsHelp
{
    /**阿里大于发送短信
     * @param $send_mobile string 发送手机号
     * @param $smsParam  string 发送内容
     * @param $appkey
     * @param $secret
     * @param $signName
     * @param $template_code
     * @return mixed
     */
    public static function aliSmsSend($send_mobile, $smsParam, $appkey, $secret, $signName, $template_code)
    {
        require_once __DIR__.'/alisms/aliyun-php-sdk-core/Config.php';
        require_once __DIR__.'/alisms/SendSmsRequest.php';
        // 短信API产品名
        $product = 'Dysmsapi';
        // 短信API产品域名
        $domain = 'dysmsapi.aliyuncs.com';
        // 暂时不支持多Region
        $region = 'cn-hangzhou';
        $profile = \DefaultProfile::getProfile($region, $appkey, $secret);
        \DefaultProfile::addEndpoint('cn-hangzhou', 'cn-hangzhou', $product, $domain);
        $acsClient = new \DefaultAcsClient($profile);

        $request = new \SendSmsRequest();
        // 必填-短信接收号码
        $request->setPhoneNumbers($send_mobile);
        // 必填-短信签名
        $request->setSignName($signName);
        // 必填-短信模板Code
        $request->setTemplateCode($template_code);
        // 选填-假如模板中存在变量需要替换则为必填(JSON格式)
        $request->setTemplateParam($smsParam);
        // 选填-发送短信流水号
        $request->setOutId("0");
        // 发起访问请求
        $acsResponse = $acsClient->getAcsResponse($request);
        return $acsResponse;
    }
}